package com.foreknow.elm.service.impl;

import com.foreknow.elm.dao.BusinessDao;
import com.foreknow.elm.dao.impl.BusinessDaoImpl;
import com.foreknow.elm.po.Business;
import com.foreknow.elm.service.BusinessService;
import com.foreknow.elm.util.DBUtil;

import java.util.List;

public class BusinessServiceImpl implements BusinessService {
    @Override
    public List<Business> listBusinessByOrderTypeId(int orderTypeId) {
        List<Business> list = null;
        try {
            BusinessDao businessDao = new BusinessDaoImpl();
            DBUtil.getConnection();
            list = businessDao.listBusinessByOrderTypeId(orderTypeId);
        } catch(Exception e) {
            e.printStackTrace();
        }finally {
            DBUtil.close();
        }
        return list;
    }

    @Override
    public Business getBusinessById(int businessId) {
        Business business = new Business();
        try {
            //创建dao层对象
            BusinessDao businessDao = new BusinessDaoImpl();
            //获取数据库连接
            DBUtil.getConnection();
            //调用dao层getConnection()方法
            business = businessDao.getBusinessById(businessId);
        }catch (Exception e) {
            e.printStackTrace();
        }finally {
            DBUtil.close();
        }
        return business;
    }
}
